﻿using SvnAPI.Base.Enumerator;
using SvnAPI.Base.Extension;
using SvnAPI.Command.Base;
using SvnAPI.Command.Interface;
using System;
using System.ComponentModel.DataAnnotations;

namespace SvnAPI.Command.Command
{
    /// <summary>
    /// 
    /// </summary>
    public sealed class SvnAdminCommand : SvnRunCommand
    {
        #region Properties

        /// <summary>
        /// Repository path to get the result.
        /// </summary>
        public String RepositoryPath { get; set; }

        /// <summary>
        /// Path in verify the result of command.
        /// </summary>
        public String PathInRepository { get; set; }

        /// <summary>
        /// Transaction or Revision number.
        /// </summary>
        public String TxnRevision { get; set; }

        #endregion

        #region Constructors

        /// <summary>
        /// Constructor for the class.
        /// </summary>
        /// <param name="txnRevision">Transaction number.</param>
        /// <param name="repositoryPath">Repository path.</param>
        /// <param name="pathInRepository">Optional parameter, path in to Verify.</param>
        public SvnAdminCommand(String txnRevision, String repositoryPath, String pathInRepository = "") : base(CommandToolType.svn_admin)
        {
            this.TxnRevision = txnRevision;
            this.RepositoryPath = repositoryPath;
            this.PathInRepository = pathInRepository;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Get the repository at RepositoryPath, then abort, thus simulating a process that crashes while holding an open repository handle.
        /// </summary>
        /// <returns>Return result of execution.</returns>
        public IResult CrashTest()
        {
            try
            {
                String operationType = SvnAdminCommandType.crash_test.GetDescription<DisplayAttribute>();

                Arguments = String.Format("{0} {1}", operationType, RepositoryPath);

                return base.Run();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isBdbLogKeep"></param>
        /// <param name="isBdbTxnNoSync"></param>
        /// <param name="isConfigDir"></param>
        /// <returns></returns>
        public IResult Create(bool isBdbLogKeep = false, bool isBdbTxnNoSync = false, bool isConfigDir = false)
        {
            // TODO
            return new Result() { ResultType = ResultType.error, Error = "Not Implemented yet." };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isBdbLogKeep"></param>
        /// <param name="isBdbTxnNoSync"></param>
        /// <param name="isConfigDir"></param>
        /// <param name="configDir"></param>
        /// <param name="isFsType"></param>
        /// <param name="fsType"></param>
        /// <returns></returns>
        public IResult Create(bool isBdbLogKeep = false, bool isBdbTxnNoSync = false, bool isConfigDir = false, string configDir = "", bool isFsType = false, FsType fsType = FsType.fsfs)
        {
            // TODO
            return new Result() { ResultType = ResultType.error, Error = "Not Implemented yet." };
        }

        #endregion        
    }
}
